package com.southwind.service;

import com.southwind.dao.MenuImp;
import com.southwind.entity.Menu;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class MenuServiceImp implements MenuService {
    @Autowired
    MenuImp menuImp;

    @Autowired
    RocketMQTemplate rocketMQTemplate;

    @Override
    public Map<String, Object> queryMenu(int menuid) {
        return menuImp.queryMenu(menuid);
    }

    @Override
    public Map<String, Object> queryRoleMenu(int menuid, int roleid) {

        Map<String, Object> result = menuImp.queryRoleMenu(menuid, roleid);

        rocketMQTemplate.convertAndSend("menuTopic", result.get("data"));

        return result;
    }

    @Override
    public Map<String, Object> insertRoleMenu(int roleid, Menu menu) {
        return menuImp.insertRoleMenu(roleid, menu);
    }
}
